package cn.kmust.booth.portal.vo;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author XChao
 * @date 2020/8/7 - 19:25
 */
@Data
@Accessors(chain = true)
public class R<T> {
    private Integer state;
    private String message;
    //相关信息
    private T data;

    public static R ok(){
        return new R().setState(State.OK);
    }

    public static <T> R ok(T data){
        return new R<T>().setState(State.OK).setData(data);
    }
    public static R failure(Integer state,String message){
        return new R().setState(state).setMessage(message);
    }

    public static R failure(Integer state,Throwable e){
        return failure(state,e.getMessage());
    }

    //内部接口
    public static interface State{
        int OK = 2000;
        int ERR_jOB_NUMBER_ISNULL = 4001;
        int ERR_PHONE_DUPLICATE = 4002;
        int ERR_INSERT = 4003;
        int ERR_JOB_NUMBER_DUPLICATE = 4004;
        int ERR_SMS_SEND=4005;
        int ERR_CODE = 4006;
        int ERR_PWD = 4007;
        int ERR_UPDATE = 4008;


        int ERR_INSERT_L = 5001;
        int ERR_DELETE = 5002;
        int ERR_UPDATE_L = 5003;
        int ERR_STALL_NOT_FOUND = 5004;
        int ERR_PERMISSION_DENIED = 5005;
        int ERR_UNKNOWN = 9999;



    }

}
